package cn.stylefeng.guns.modular.tool.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.tool.entity.ToolExpressExcel;
import cn.stylefeng.guns.modular.tool.model.params.ToolExpressExcelParam;
import cn.stylefeng.guns.modular.tool.service.ToolExpressExcelService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import cn.stylefeng.guns.sys.modular.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 快递统计导入控制器
 */
@Controller
@RequestMapping("/toolExpressExcel")
public class ToolExpressExcelController extends BaseController {

    private String PREFIX = "/tool/toolExpressExcel";

    @Autowired
    private ToolExpressExcelService toolExpressExcelService;

    @Autowired
    private UserService userService;

    /**
     * 跳转到主页面
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/toolExpressExcel.html";
    }

    /**
     * 新增页面
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/toolExpressExcel_add.html";
    }

    /**
     * 编辑页面
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/toolExpressExcel_edit.html";
    }

    /**
     * 新增接口
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(ToolExpressExcelParam toolExpressExcelParam) {
        this.toolExpressExcelService.add(toolExpressExcelParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(ToolExpressExcelParam toolExpressExcelParam) {
        this.toolExpressExcelService.update(toolExpressExcelParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(ToolExpressExcelParam toolExpressExcelParam) {
        this.toolExpressExcelService.delete(toolExpressExcelParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(ToolExpressExcelParam toolExpressExcelParam) {
        ToolExpressExcel detail = this.toolExpressExcelService.getById(toolExpressExcelParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(ToolExpressExcelParam toolExpressExcelParam,String condition ) {
        return this.toolExpressExcelService.findPageBySpec(toolExpressExcelParam,condition);
    }

}


